Skip to content

Conversation

@wellingtoncosta
Copy link
Collaborator

@wellingtoncosta wellingtoncosta commented Jan 6, 2026

Summary

Implements cursor hiding behavior on macOS when typing in text fields, matching the native IDE behavior. The cursor automatically hides when the user types and reappears when the mouse moves.

Evidence

Screen.Recording.2026-01-06.at.6.37.57.PM.mov

Implementation Details

Architecture

Added a platform-specific cursor controller abstraction using Compose composition locals:

  • PlatformCursorController - Interface for platform-specific cursor control
  • StandalonePlatformCursorController - macOS implementation using JNA to call [NSCursor setHiddenUntilMouseMoves:YES]
  • BridgePlatformCursorController - Bridge implementation using MacUIUtil.hideCursor()
  • NoOpPlatformCursorController - Fallback for unsupported platforms

Integration

  • Applied to all InputField components via .hideCursorOnTyping() modifier
  • Only active when field is enabled and not read-only
  • Provided via LocalPlatformCursorController composition local:
    • IntUiThemeStandalonePlatformCursorController
    • SwingBridgeThemeBridgePlatformCursorController

Release notes

New features

  • Input Fields: Added automatic cursor hiding on macOS when typing. The cursor hides while typing and reappears when the mouse moves, matching the native macOS behavior seen in IntelliJ Platform text fields (JEWEL-992).

Note

Implements macOS cursor-hiding behavior and abstracts platform-specific control.

  • Adds PlatformCursorController and LocalPlatformCursorController composition local
  • macOS implementations: BridgePlatformCursorController (uses MacUIUtil.hideCursor()), StandalonePlatformCursorController (uses JNA to call [NSCursor setHiddenUntilMouseMoves:])
  • Themes provide the controller: SwingBridgeThemeBridgePlatformCursorController, IntUiThemeStandalonePlatformCursorController
  • Integrates with InputField via .hideCursorOnTyping() (key preview on keydown; active only when enabled and not read-only)
  • Build: adds JNA dependency to standalone module (Bazel/Gradle); API dump updated

Written by Cursor Bugbot for commit fbc46c1. This will update automatically on new commits. Configure here.

Copy link
Collaborator

@faogustavo faogustavo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blockers :)

@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from 3c1838d to 8f771d3 Compare January 7, 2026 14:34
@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from 8f771d3 to e3fc7bf Compare January 13, 2026 22:27
@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from e3fc7bf to cd4537d Compare January 13, 2026 22:33
Copy link
Collaborator

@rock3r rock3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Couple minor notes

@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from cd4537d to f5f2c94 Compare January 14, 2026 13:09
Copy link
Collaborator

@rock3r rock3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from f5f2c94 to fbc46c1 Compare January 15, 2026 14:49
*/
public interface PlatformCursorController {
/** Hides the mouse cursor while the user is typing. This is a MacOS-only behavior. */
public fun hideCursorWhileTyping()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name hideCursorWhileTyping() doesn't really match what it actually does. Looking at the implementation, it hides the cursor until the next mouse movement on macOS, and does nothing on Windows/Linux.
The name suggests the cursor is hidden while you're actively typing, but it actually stays hidden until you move the mouse - even if you stop typing. Also, the platform-specific behavior isn't obvious from just looking at the function name.

A couple of options to fix this:

  1. Rename it to something like hideCursorUntilMouseMoves() or hideCursorWhileIdle() to better describe what's actually happening
  2. Or restructure the PlatformCursorController to actually handle typing events internally and decide when to hide/show the cursor, making it work more like the name suggests

Either way, could you add some documentation about the Windows/Linux behavior? Right now it's not clear that it's a no-op on those platforms.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with solution 2, let's keep component-specific behaviour in the component itself. We may have other uses for hiding the cursor in the future, we shouldn't leak the specific use case in the composition local.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nebojsa-vuksic I'm not sure if the renaming suggestions are also helpful to explicitly describe what this function does. Maybe just keep it as hideCursor() as it is in the legacy code, and add a little bit more of documentation explaining what it does and when the cursor should be displayed again.

Something like:

/**
 * Hides the mouse cursor while the user is typing. The cursor stays hidden until the next mouse movement.
 *
 * This is a macOS-only behavior. The cursor remains visible on Windows and Linux.
 */
public fun hideCursor()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also drop Hides the mouse cursor while the user is typing. part since it has nothing to do with mouse visibility in this context. Mouse visibility is only affected by it's movement, as your next sentence states. :) In this case, with a proper kdoc, I'm fine with hideCursor function name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nebojsa-vuksic @rock3r done. Please review again once you have a chance.

Copy link
Collaborator

@nebojsa-vuksic nebojsa-vuksic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at the comment about a design of PlatformCursorController.

@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from fbc46c1 to eeaad22 Compare January 20, 2026 17:25
@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from eeaad22 to b646396 Compare January 20, 2026 17:48
@rock3r
Copy link
Collaborator

rock3r commented Jan 21, 2026

Ready to merge

@wellingtoncosta wellingtoncosta force-pushed the wp/hide-cursor-while-typing-macos branch from b646396 to cb93c96 Compare January 21, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants